<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>从数组元素创建一个 ReflectionReference</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reflectionreference.construct.html">« ReflectionReference::__construct</a></li>
      <li style="float: right;"><a href="reflectionreference.getid.html">ReflectionReference::getId »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.reflectionreference.html">ReflectionReference</a></li>
    <li>从数组元素创建一个 ReflectionReference</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reflectionreference.fromarrayelement" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionReference::fromArrayElement</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.4.0, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionReference::fromArrayElement</span> &mdash; <span class="dc-title">从数组元素创建一个 ReflectionReference</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionreference.fromarrayelement-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>ReflectionReference::fromArrayElement</strong></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$array</code></span>, <span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type">string</span></span> <code class="parameter">$key</code></span>): <span class="type"><span class="type">?</span><span class="type"><a href="class.reflectionreference.html" class="type ReflectionReference">ReflectionReference</a></span></span></div>

  <p class="para rdfs-comment">
   从数组元素创建一个 <span class="classname"><a href="class.reflectionreference.html" class="classname">ReflectionReference</a></span>。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionreference.fromarrayelement-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">array</code></dt>

    <dd>

     <p class="para">
      包含潜在引用的 <span class="type">array</span>。
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">key</code></dt>

    <dd>

     <p class="para">
      一个 <span class="type">int</span> 或者 <span class="type">string</span> 类型的 key。
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionreference.fromarrayelement-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   如果 <code class="literal">$array[$key]</code> 是引用，返回 <span class="classname"><strong class="classname">ReflectionReference </strong></span>
   实例，否则返回 <strong><code>null</code></strong>。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-reflectionreference.fromarrayelement-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   如果 <code class="parameter">array</code> 不是一个 <span class="type">array</span>，或者 <code class="parameter">key</code>
   不是 <span class="type">int</span> 或者 <span class="type">string</span> 类型，会抛出 <span class="classname"><a href="class.typeerror.html" class="classname">TypeError</a></span>。
   如果 <code class="literal">$array[$key]</code> 不存在，
   会抛出 <span class="classname"><a href="class.reflectionexception.html" class="classname">ReflectionException</a></span>。
  </p>
 </div>


</div></div></div></body></html>